|
1
|
|
|
GLSR.colorControls = function() |
|
|
|
|
|
|
2
|
|
|
{ |
|
3
|
|
|
if( typeof x.wp !== 'object' || typeof x.wp.wpColorPicker !== 'function' )return; |
|
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
x( document ).find( 'input[type="text"].color-picker-hex' ).each( function() { |
|
6
|
|
|
var t = x( this ); |
|
7
|
|
|
var options = t.data( 'colorpicker' ) || {}; |
|
8
|
|
|
t.wpColorPicker( options ); |
|
9
|
|
|
}); |
|
10
|
|
|
}; |
|
11
|
|
|
|
|
12
|
|
|
GLSR.dismissNotices = function() |
|
|
|
|
|
|
13
|
|
|
{ |
|
14
|
|
|
x( '.notice.is-dismissible' ).each( function() { |
|
15
|
|
|
var notice = x( this ); |
|
16
|
|
|
notice.fadeTo( 100, 0, function() { |
|
17
|
|
|
notice.slideUp( 100, function() { |
|
18
|
|
|
notice.remove(); |
|
19
|
|
|
}); |
|
20
|
|
|
}); |
|
21
|
|
|
}); |
|
22
|
|
|
}; |
|
23
|
|
|
|
|
24
|
|
|
GLSR.getURLParameter = function( name ) |
|
|
|
|
|
|
25
|
|
|
{ |
|
26
|
|
|
return decodeURIComponent( |
|
27
|
|
|
(new RegExp( '[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)' ).exec( location.search ) || [null, ''])[1].replace( /\+/g, '%20' ) |
|
28
|
|
|
) || null; |
|
29
|
|
|
}; |
|
30
|
|
|
|
|
31
|
|
|
GLSR.insertNotices = function( notices ) |
|
|
|
|
|
|
32
|
|
|
{ |
|
33
|
|
|
if( !notices )return; |
|
|
|
|
|
|
34
|
|
|
if( !x( '#glsr-notices' ).length ) { |
|
35
|
|
|
x( '#message.notice' ).remove(); |
|
36
|
|
|
x( 'form#post' ).before( '<div id="glsr-notices" />' ); |
|
37
|
|
|
} |
|
38
|
|
|
x( '#glsr-notices' ).html( notices ); |
|
39
|
|
|
x( document ).trigger( 'wp-updates-notice-added' ); |
|
40
|
|
|
}; |
|
41
|
|
|
|
|
42
|
|
|
GLSR.isUndefined = function( value ) |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
|
return value === void(0); |
|
|
|
|
|
|
45
|
|
|
}; |
|
46
|
|
|
|
|
47
|
|
|
GLSR.onChangeStatus = function( ev ) |
|
|
|
|
|
|
48
|
|
|
{ |
|
49
|
|
|
var post_id = this.href.match(/post=([0-9]+)/)[1]; |
|
50
|
|
|
var status = this.href.match(/action=([a-z]+)/)[1]; |
|
51
|
|
|
|
|
52
|
|
|
if( GLSR.isUndefined( status ) || GLSR.isUndefined( post_id ))return; |
|
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
var request = { |
|
55
|
|
|
action: 'change-review-status', |
|
56
|
|
|
status : status, |
|
57
|
|
|
post_id: post_id, |
|
58
|
|
|
}; |
|
59
|
|
|
|
|
60
|
|
|
GLSR.postAjax( ev, request, function( response ) |
|
61
|
|
|
{ |
|
62
|
|
|
var el = x( ev.target ); |
|
63
|
|
|
if( !response.class )return; |
|
|
|
|
|
|
64
|
|
|
el.closest( 'tr' ).removeClass( 'status-pending status-publish' ).addClass( response.class ); |
|
65
|
|
|
el.closest( 'td.column-title' ).find( 'strong' ).html( response.link ); |
|
66
|
|
|
}); |
|
67
|
|
|
}; |
|
68
|
|
|
|
|
69
|
|
|
GLSR.onClearLog = function( ev ) |
|
|
|
|
|
|
70
|
|
|
{ |
|
71
|
|
|
var request = { |
|
72
|
|
|
action: 'clear-log', |
|
73
|
|
|
}; |
|
74
|
|
|
GLSR.postAjax( ev, request, function( response ) |
|
|
|
|
|
|
75
|
|
|
{ |
|
76
|
|
|
GLSR.insertNotices( response.notices ); |
|
|
|
|
|
|
77
|
|
|
x( '#log-file' ).val( response.logger ); |
|
78
|
|
|
}); |
|
79
|
|
|
}; |
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
GLSR.pointers = function( pointer ) |
|
84
|
|
|
{ |
|
85
|
|
|
x( pointer.target ).pointer({ |
|
86
|
|
|
content: pointer.options.content, |
|
87
|
|
|
position: pointer.options.position, |
|
88
|
|
|
close: function() { |
|
89
|
|
|
x.post( ajaxurl, { |
|
|
|
|
|
|
90
|
|
|
pointer: pointer.id, |
|
91
|
|
|
action: 'dismiss-wp-pointer', |
|
92
|
|
|
}); |
|
93
|
|
|
}, |
|
94
|
|
|
}) |
|
95
|
|
|
.pointer( 'open' ) |
|
96
|
|
|
.pointer( 'sendToTop' ); |
|
97
|
|
|
|
|
98
|
|
|
x( document ).on( 'wp-window-resized', function() { |
|
99
|
|
|
x( pointer.target ).pointer( 'reposition' ); |
|
100
|
|
|
}); |
|
101
|
|
|
}; |
|
102
|
|
|
|
|
103
|
|
|
GLSR.postAjax = function( ev, request, callback ) |
|
|
|
|
|
|
104
|
|
|
{ |
|
105
|
|
|
ev.preventDefault(); |
|
106
|
|
|
var el = x( ev.target ); |
|
107
|
|
|
if( el.is( ':disabled' ))return; |
|
|
|
|
|
|
108
|
|
|
request.nonce = request.nonce || el.closest( 'form' ).find( '#_wpnonce' ).val(); |
|
109
|
|
|
var data = { |
|
110
|
|
|
action: site_reviews.action, |
|
|
|
|
|
|
111
|
|
|
request: request, |
|
112
|
|
|
}; |
|
113
|
|
|
el.prop( 'disabled', true ); |
|
114
|
|
|
x.post( site_reviews.ajaxurl, data, function( response ) { |
|
|
|
|
|
|
115
|
|
|
if( typeof callback === 'function' ) { |
|
116
|
|
|
callback( response ); |
|
117
|
|
|
} |
|
118
|
|
|
el.prop( 'disabled', false ); |
|
119
|
|
|
}); |
|
120
|
|
|
}; |
|
121
|
|
|
|
|
122
|
|
|
GLSR.textareaResize = function( el ) |
|
|
|
|
|
|
123
|
|
|
{ |
|
124
|
|
|
var minHeight = 320; |
|
125
|
|
|
var textarea = el[0]; |
|
126
|
|
|
|
|
127
|
|
|
textarea.style.height = 'auto'; |
|
128
|
|
|
|
|
129
|
|
|
textarea.style.height = textarea.scrollHeight > minHeight ? |
|
130
|
|
|
textarea.scrollHeight + 'px' : |
|
131
|
|
|
minHeight + 'px'; |
|
132
|
|
|
}; |
|
133
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.